<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="../language.jsp" %>
<%
	request.setAttribute("registerLocation",request.getParameter("registerLocation"));
	request.setAttribute("contactNo",request.getParameter("contactNo"));
	request.setAttribute("recommendUser",request.getParameter("recommendUser"));
	request.setAttribute("declarationCenters",request.getParameter("declarationCenters"));
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title><fmt:message key="i18n.userReg" />-<fmt:message key="i18n.title"/></title>
<link rel="shortcut icon" href="../images/favicon.png" />
<link rel="stylesheet" type="text/css" href="css/style1.css" />
<link href="../skin/skin1/css/css.css" rel="stylesheet"/>
<link href="../styles/artDialog-default.css" rel="stylesheet" />
<script type="text/javascript" src="../scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../scripts/jquery.artDialog.min.js"></script>
<script type="text/javascript" src="../scripts/user/common.js"></script>
<script type="text/javascript" src="../scripts/user/reguser.js"></script>
<script type="text/javascript">
var winHeight = $(window).height(); 
function readUserAgreement(){
	$.dialog({
	    title: '<fmt:message key="i18n.lookAgreement"/>',lock: true,
	    width: 620, height: (winHeight * 0.6),//仅能为数字
	    content: $('#userAgreement').html(),
	    okValue: '<fmt:message key="i18n.consentAgreement"/>', ok: function () {
	    	$("#register_form").submit();
	    },
		cancelValue: ' <fmt:message key="i18n.cancel"/> ', cancel: function () {
	    }
	});
}
$(function(){

	$("#getRegisterCode").click(function(){
		window.location.href="lottery.jsp"
	});
	$("#register_form_submit").click(function(){
		/* alert($("#registerPwdCheck").val()); alert($("#registerPwd").val());return; */
		if( $("#registerAccount").val() === ""){
			alert( "登入账号不允许为空!" ); 
			$("#registerAccount").focus();
			return;
		}
		
		var re =new RegExp("^[A-Za-z0-9]{6,10}$");
		if (!re.test($('#registerAccount').val())){
			alert("登入账号最少6位，只能由英文和数字组成！");
			$('#registerAccount').focus();
			return;
		}
		
		if( $("#registerPwd").val() === ""){
			alert( "登陆密码不允许为空!" ); $("#registerPwd").focus();return;
		}
		/* if( $("#registerPwdCheck").val() === ""){
			alert( "Confirm Password does not allow null(确认密码不允许为空)!" ); $("#registerPwdCheck").focus();return;
		} */
		if( $("#registerPwdCheck").val() !== $("#registerPwd").val()){
			alert( "两次密码不一致，请检查输入!" ); $("#registerPwdCheck").focus();return;
		}
		
		if( $("#registerMobile").val() === ""){
			alert( "手机号码不允许为空!" ); $("#registerMobile").focus();return;
		}
		
		if( !checkMobile($("#registerMobile").val())){
			alert( "手机号码不正确!" ); $("#registerMobile").focus();return;
		}
		
		if( $("#registerAuthCode").val() === ""){
			alert( "请输入手机收到的验证码!" ); $("#registerAuthCode").focus();return;
		}
		readUserAgreement();
		//$("#register_form").submit();
	});
	var resultStr = "${resultStr}";var loginName = "${resultStrLoginName}";
	if ( loginName !== "" && resultStr !== ""){
		//alert( resultStr );
		$("#registerAccount").val( loginName );
		if("SUCCESSFUL" === resultStr){
			alert( "注册成功,系统将自动跳转到登录页面" );
			window.location.href = "login.jsp"
		}else if("ACTIVATION_CODE_ERROR" === resultStr){
			alert( "验证码错误" );
		}else if("LOGINNAME_ALREADY_REGISTERED" === resultStr){
			alert( "此账号已经被注册" );
		}else if("ERROR_PARAM" === resultStr){
			alert( "输入参数错误，请检查输入" );
		}else if("REGISTER_CODE_INVALID" === resultStr){
			alert( "注册码无效" );
		}else{
			alert( resultStr );
		}
	}else{
		//alert(2);
	}
});
</script>
</head>
<body style="background-color: white;">

	<div class="logoTop">
		<div class="logo"><a href="#"><img src="img/white-sp.png" border="0"></a></div>
	</div>
  <div class="Login logoCont" >
  <div class="logoCont1200">
    <form action="registerUser!regiserUser.action" method="post" id="register_form">
    	<input type="hidden" name="registerUserDTO.recommendUser" value="${recommendUser }"/>
        <input type="hidden" name="registerUserDTO.contactNo" value="${contactNo }"/>
        <input type="hidden" name="registerUserDTO.registerLocation" value="${registerLocation}"/>
      <h2>
      	<fmt:message key="i18n.newUserReg" />
      
      	<span style="float: right;padding-right: 10px;font-size: 14px;">
      		<a href="login.jsp">&gt;&gt;<fmt:message key="i18n.login" /></a>
      	</span>
      </h2>
      
      <div class="bd">
        <ul>
          <li>
            <div class="left"><i>*</i>登入账号：</div>
            <div class="right"><input type="text" name="registerUserDTO.loginName" id="registerAccount" onBlur="checkLoginNameIsExistAndShow('registerAccount','showResult')" placeholder="请输入您的账号" class="srk1"/>
            	<span style="color: red;" id="showResult"></span>
            </div>
          </li>
          <li>
            <div class="left"><i>*</i><fmt:message key="i18n.loginPassword" />：</div>
            <div class="right"><input type="password" name="registerUserDTO.password1" id="registerPwd" placeholder="<fmt:message key="i18n.regInputPwd" />" class="srk1"/></div>
          </li>
          <li>
            <div class="left"><i>*</i><fmt:message key="i18n.cofimPassword" />：</div>
            <div class="right"><input type="password" placeholder="<fmt:message key="i18n.regInputRepwd" />" id="registerPwdCheck" class="srk1"/></div>
          </li>
          <li>
            <div class="left"><i>*</i>手机号码：</div>
            <div class="right"><input type="text" name="registerUserDTO.mobile" id="registerMobile" placeholder="请输入您的手机号码" class="srk1"/></div>
          </li>
          <%-- 
          <li>
            <div class="left"><i>*</i>激活码：</div>
            <div class="right"><input type="text" name="registerUserDTO.registerCode" placeholder="4~6位数字字母" class="srk2">
            	<input id="getRegisterCode" type="button" value="获取激活码" class="yz"><br>
            </div>
          </li>
          --%>
          <li>
            <div class="left"><i>*</i><fmt:message key="i18n.mobileCode" />：</div>
            <div class="right">
            	<input type="text" id="registerAuthCode" name="registerUserDTO.authCode" placeholder="<fmt:message key="i18n.regInputVerificationCode" />" class="srk2"/>
            	<input id="getRegisterAuthCode" onclick="getVerificationCode('Mobile','Register','#registerMobile','#getRegisterAuthCode')" type="button" value="<fmt:message key="i18n.getVerificationCode" />" class="yz"/><br/>
            	<!-- <span id="registerAccount_show">&nbsp;</span> -->
            </div>
          </li>
         <!--  <li style="text-align:left; padding-left:205px;">
            <a href="javascript:test();">查看用户协议</a>&nbsp;
          </li> -->
          <li>
            <input id="register_form_submit" type="button" value="<fmt:message key="i18n.lookAgreement"/>" class="ty_an"/>
          </li>
        </ul>
      </div>
    </form>
    </div>
  </div>
  <div id="userAgreement" style="display: none;font-size: 14px;"><jsp:include page="userAgreement.jsp" /></div>
  <div class="logoBottom">
		<span class="logoBottom1">企业备案：闽ICP备16015749号-1   版权所有：2016 | 科百特(厦门)信息科技有限公司</span>
		<span class="logoBottom2"></span>
		<span class="logoBottom3"><a href="#"><img style="width:auto;height:45px;" src="../skin/skin1/img/logo.png" border="0"></a></span>
	</div>
</body>
</html>
<% 
session.setAttribute("resultStr", null);
session.setAttribute("resultStrLoginName", null);
%>